{php $child = get_maincat(0, $mid, 1);}
{loop $child $i $c}
<li class="over">
<a href="{$MODULE[$mid][linkurl]}{$c[linkurl]}" target="_blank">{set_style($c[catname], $c[style])}</a>
{if $c[child]}
  {php $sub = get_maincat($c[catid], $mid, 1);}                                
  <ul class="kkk"> 
  {loop $sub $j $s}
    <li><a href="{$MODULE[$mid][linkurl]}{$s[linkurl]}" target="_blank">{set_style($s[catname], $s[style])}</a></li>
  {/loop} 
  </ul>
  {/if} 
  </li>
{/loop} 

<p onclick="return chg('kkk');" class="hidden-1"id="hidden-more">More Categories</p>
<ul id="kkk" style="display:none;">
{php $child = get_maincat(0, $mid, 2);}
{loop $child $k $v}
<li class="over">
<a href="{$MODULE[$mid][linkurl]}{$v[linkurl]}" target="_blank">{set_style($v[catname], $v[style])}</a>
{if $c[child]}
  {php $sub = get_maincat($v[catid], $mid, 1);}                                
  <ul class="kkk"> 
  {loop $sub $t $b}
    <li><a href="{$MODULE[$mid][linkurl]}{$b[linkurl]}" target="_blank">{set_style($b[catname], $b[style])}</a></li>
  {/loop} 
  </ul>
  {/if} 
  </li>
{/loop}
</ul>
 